package shClient;

import java.io.*;
import java.net.*;

import edu.fhsu.csci468.SensorAction;
import edu.fhsu.csci468.SensorType;


public class SensorClient 
{
	
//	static String ip = "209.114.100.80";
	static String ip = "127.0.0.1";
	
	public static void main(String [] agrs)
	{
		try
		{
			Socket s = new Socket(InetAddress.getByName(ip), 8189);
			System.out.println("Contected to Sever " + ip);
			try
			{				
				ObjectOutputStream outStream = new ObjectOutputStream(
						new BufferedOutputStream(s.getOutputStream()));
				outStream.flush();
				
				System.out.println("Got stream");
				
				outStream.writeObject(SensorType.Smoke);
				outStream.flush();
				
				outStream.writeObject(SensorAction.Trigger);
				outStream.flush();
				
				try
				{
					Thread.sleep(10000);
				}
				catch (Exception e) {
					// TODO: handle exception
				}
				
				outStream.writeObject(SensorAction.Discontect);
				outStream.flush();
				
				
			}
			finally
			{
				s.close();
			}
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}

}
